var express = require('express');
var router = express.Router();
const TeamTvController = require("../controllers/Team_controller")
// 获取小组列表
router.get("/Team", (req, res) => {
    var {
        page,
        pagesize
    } = req.query

    TeamTvController.TeamTVlist({
        page,
        pagesize
    }, ["查询失败", "查询成功"], (result) => {
        res.json(result)
    })
})
// 添加小组
router.post("/addTeamTv", (req, res) => {
    const {
        TeamTvObj
    } = req.body
    // const {
    //     doubanId,
    //     title,
    //     rate,
    //     poster
    // } = req.body
    // {
    //     doubanId: Number(doubanId),
    //     title,
    //     rate: Number(rate),
    //     poster
    // }
    TeamTvController.addTeamTvlist(TeamTvObj, ["添加失败", "添加成功"], (result) => {
        res.json(result)
    })
})
// 修改小组信息
router.patch("/patchTeamTv", (req, res) => {
    const {
        TeamTvObj
    } = req.body
    // const {
    //     doubanId,
    //     title,
    //     rate,
    //     poster
    // } = req.body
    // {
    //     doubanId: Number(doubanId),
    //     title,
    //     rate: Number(rate),
    //     poster
    // }
    TeamTvController.patchTeamTvlist(TeamTvObj, ["修改失败", "修改成功"], (result) => {
        res.json(result)
    })
})
//删除小组
router.delete("/deleteTeamTv", (req, res) => {
    const {TeamTvId}=req.body
    TeamTvController.deleteTeamTvlist(TeamTvId, ["删除失败", "删除成功"], (result) => {
        res.json(result)
    })
})

module.exports = router;
